package edu.caece.langprocessor.semantic;

public class SymbolsTableItem {

	private Integer level;
	private SymbolType type;
	private String id;
	private Integer hashcode;
	
	public SymbolsTableItem(String id, SymbolType type, Integer level){
		this.id = id;
		this.type = type;
		this.level = level;

		String hashcode = this.id + this.type + this.level.toString();
		this.hashcode = hashcode.hashCode();
	}
	
	public Integer getLevel() {
		return level;
	}
	public SymbolType getType() {
		return type;
	}
	public String getId() {
		return id;
	}
	
	@Override
	public String toString() {
		return "[id:" + this.id + " type:"+ this.type + " level:" + this.level.toString() +"]";
	}
	
	@Override
	public boolean equals(Object obj) {
		boolean isEquals = false;
		if (obj instanceof SymbolsTableItem){
			SymbolsTableItem other = (SymbolsTableItem) obj;
			isEquals = (this.level.equals(other.getLevel()));
			isEquals = isEquals && (this.id.equals(other.getId()));
			isEquals = isEquals && (this.type.equals(other.getType()));
		}
		return isEquals;
	}
	
	@Override
	public int hashCode() {
		return this.hashcode;
	}
}
